﻿using AnalogInput;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AnalogQuantityAcquisition
{
    class Program
    {
        static void Main(string[] args)
        {
            DeviceComm deviceComm = new DeviceComm();
            deviceComm.Address = "192.168.1.232";//232
            deviceComm.Port = 10000;//10000
            deviceComm.AnalogEvent += DeviceComm_AnalogEvent;
            deviceComm.Ready();
            while (true)
            {
                Random random = new Random();
                var a= (ushort)random.Next(100,1000);
                deviceComm.WriteValueAsync(new ushort[8] { 1,2, a, 4,5,6,7,8});
                Thread.Sleep(5000);
            }
        }

        private static void DeviceComm_AnalogEvent(ConcurrentDictionary<int, float> obj)
        {
            for (int i = 0; i < obj.Count; i++)
            {
                Console.WriteLine("通道："+i+"，"+"值："+obj[i]);
            }
        }
    }
}
